//
//  mluLawyerPreferences.m
//  mluLawyer
//
//  Created by GecanMobile01 on 27/11/09.
//  Copyright 2009 MobileLifeUtils.com. All rights reserved.
//

#import "mluLawyerPreferences.h"

@implementation mluLawyerPreferences
@synthesize mocPreferences, maPreferencesAuxiliarData, maPreferencesSectionsOptions, maPreferencesSectionsTitles;

- (id)initWithStyle:(UITableViewStyle)style {
	// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
	self.title = NSLocalizedString(@"titSettings", nil);
    if (self = [super initWithStyle:style]) {
    }
    return self;
}

- (void)viewDidLoad {
	maPreferencesSectionsTitles = [[NSMutableArray alloc] initWithObjects:
								   NSLocalizedString(@"titAuxiliarData", nil),
								   nil
								   ];
	
	NSArray *aAuxiliarData = [[NSArray alloc] initWithObjects:
							  NSLocalizedString(@"titCaseSituations", nil),
							  NSLocalizedString(@"titContactTypes", nil),
							  NSLocalizedString(@"titDocumentTypes", nil),
							  NSLocalizedString(@"titParticipationTypes", nil),
							  NSLocalizedString(@"titSpheres", nil),
							  nil
							  ];
	
	
	mluLawyerCaseSituationsList *vcCaseSituations = [[mluLawyerCaseSituationsList alloc] init];
	vcCaseSituations.mocCaseSituations = mocPreferences;
	mluLawyerSpheresList *vcSpheres = [[mluLawyerSpheresList alloc] init];
	
	
	maPreferencesAuxiliarData = [[NSMutableArray alloc] initWithObjects:
								 vcCaseSituations,
								 vcSpheres,
								 nil
								 ];
	
	maPreferencesSectionsOptions = [[NSMutableArray alloc] initWithObjects:
									aAuxiliarData,
									nil
									];
	
	[super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated {
	self.navigationController.toolbarHidden = YES;
	[super viewWillAppear:animated];
}

/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
	[super viewDidDisappear:animated];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

#pragma mark -
#pragma mark UITableViewDelegate methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [maPreferencesSectionsTitles count];
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {	
	return [[maPreferencesSectionsOptions objectAtIndex:section] count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
	return [maPreferencesSectionsTitles objectAtIndex:section];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    UILabel *lblCell = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 10.0, 200.0, 25.0)];
	[lblCell setText:[[maPreferencesSectionsOptions objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]];
	[cell addSubview:lblCell];
	
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.navigationController pushViewController:[maPreferencesAuxiliarData objectAtIndex:indexPath.row] animated:YES];
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/


/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/


- (void)dealloc {
    [super dealloc];
}


@end

